﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using COFE.Core.Utils;

namespace COFE.Core
{
    public class ResourceFilter : IPropertyFilter
    {
        #region Constructor

        public ResourceFilter(MediaType mediaType)
        {
            _mediaType = mediaType;            
        }

        public ResourceFilter()
        {
        }

        #endregion

        #region Methods

        public bool Match(object property)
        {
            var ra = EnumUtils<ResourceAttribute>.FindAttribute(property);
            if (ra != null)
            {
                if (_mediaType.HasValue)
                    if (ra.MediaType != _mediaType.Value)
                        return false;

                return true;
            }
            return false;
        }

        #endregion

        #region Data

        private MediaType? _mediaType;
        

        #endregion

        #region Public Properties

        #endregion
    }
}
